package org.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class GetTest extends HttpServlet {
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		System.out.println(">>>搜索引擎正在为你查找资源。。。。");
		PrintWriter out = resp.getWriter();
		System.out.println(">>>设置响应状态200。。。");
		resp.setStatus(200);
		System.out.println(">>>设置响应格式text/html");
		resp.setContentType("text/html");
		System.out.println(">>>设置响应编码UTF-8");
		resp.setCharacterEncoding("UTF-8");
		out.println(req.getProtocol() + " " + resp.getStatus() + " OK");
		out.println("Connection: keep-alive");
		out.println("Content-Type: " + req.getContentType());
		out.println("Content-Length: " + req.getContentLength());
		out.println("Date: " + new Date(System.currentTimeMillis()).toString());
		out.println("Server: Monster-1.0/1.1");
		out.println("");
		out.println("<html>"
				+ "<head><title>Insert title here</title></head>"
				+ "<body><ul><li>网站一</li><li>网站二</li><li>网站三</li><li>网站四</li></ul></body>"
				+ "</html>");
		out.flush();
	}
}
